package class41To50;

import java.io.*;

public class DeleteAgainAndAgain {

    public static int MAX_N = 1000001;

    public static int[] next = new int[MAX_N];

    public static char[] s1;

    public static char[] s2;

    public static int size;

    public static char stack1[] = new char[MAX_N];

    public static int stack2[] = new int[MAX_N];


    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        s1 = in.readLine().toCharArray();
        s2 = in.readLine().toCharArray();
        computeRet();
        for (int i = 0; i < size; i++) {
            out.print(stack1[i]);
        }
        out.println();
        out.flush();
        out.close();
        in.close();
    }

    private static void computeRet() {
        size = 0;
        int n = s1.length;
        int m = s2.length;
        nextArray(s2);
        int x = 0;
        int y = 0;
        while (x < n) {
            if (s1[x] == s2[y]) {
                stack1[size] = s1[x];
                stack2[size] = y;
                size++;
                x++;
                y++;
            } else if (y > 0) {
                y = next[y];
            } else {
                stack1[size] = s1[x];
                stack2[size] = -1;
                size++;
                x++;
            }
            if (y == m) {
                size -= m;
                y = size > 0 ? (stack2[size - 1] + 1) : 0;
            }
        }
    }

    private static void nextArray(char[] s) {
        int m = s.length;
        next[0] = -1;
        next[1] = 0;
        int i = 2;
        int cn = 0;
        while (i < m) {
            if (s[i - 1] == s[cn]) {
                next[i++] = ++cn;
            } else if (cn > 0) {
                cn = next[cn];
            } else {
                next[i++] = 0;
            }
        }
    }
}
